package com.hzsk.lisence.strategy;

import com.hzsk.lisence.config.myexception.BaseException;
import com.hzsk.lisence.enums.ChannelEnum;
import com.hzsk.lisence.enums.FunctionItemEnum;
import com.hzsk.lisence.enums.ProdTypeEnum;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * 玻璃机授权功能项
 */
@Service
public class GlassMachineFunctionListStrategy implements FunctionListStrategy{
    @Override
    public Boolean shouldCheck(String prodType) {
        return ProdTypeEnum.GlassMachine.getCode().equals(prodType);
    }

    @Override
    public Boolean check(String channelNum, String functions) throws BaseException {
        if (!ChannelEnum.OneChannel.getCode().equals(channelNum)&&
                !ChannelEnum.TwoChannel.getCode().equals(channelNum)&&
                !ChannelEnum.FourChannel.getCode().equals(channelNum)){
            throw new BaseException("玻璃机产品只能授权单通道或双通道或四通道");
        }
        if (StringUtils.isNotEmpty(functions)&&functions.contains(FunctionItemEnum.FourAxisDirectionalMachining.getCode())){
            throw new BaseException("玻璃机产品无需四轴定向加工功能授权");
        }
        if (StringUtils.isNotEmpty(functions)&&functions.contains(FunctionItemEnum.SevenAxisRTCPFunction.getCode())){
            throw new BaseException("玻璃机产品无需七轴RTCP功能授权");
        }
        if (StringUtils.isNotEmpty(functions)&&functions.contains(FunctionItemEnum.FiveAxisHomogenization.getCode())){
            throw new BaseException("玻璃机产品无需五轴均化功能授权");
        }
        if (StringUtils.isNotEmpty(functions)&&functions.contains(FunctionItemEnum.AntiCollisionFunction.getCode())){
            throw new BaseException("玻璃机产品无需防碰撞功能授权");
        }
        if (StringUtils.isNotEmpty(functions)&&functions.contains(FunctionItemEnum.LoadAdaptiveFunction.getCode())){
            throw new BaseException("玻璃机产品无需负载自适应功能授权");
        }
        if (StringUtils.isNotEmpty(functions)&&functions.contains(FunctionItemEnum.SpaceArcCommand.getCode())){
            throw new BaseException("玻璃机产品无需空间圆弧指令CIP功能授权");
        }
        return true;
    }
}
